package com.example.springmvcdemo.controller;

import java.io.*;
import java.util.Arrays;

import org.junit.Test;


//测试读resources中文件
public class IOTest {
    public static void main(String[] args) throws FileNotFoundException {

    }

    @Test
    public void test1() throws IOException {
        File file = new File(this.getClass().getResource("/application.properties").getPath());
        FileInputStream inputStream = new FileInputStream(file);
        System.out.println(inputStream);
        byte[] buffer = new byte[1024];
        int len;
        while ((len = (inputStream.read(buffer))) != -1) {
            System.out.println(new String(buffer, 0, len));
        }

        FileReader reader = new FileReader(file);
/*        char[] c = new char[16];
        reader.read(c);
        System.out.println(Arrays.toString(c));*/
        int b;
        System.out.println(".............");
        while ((b = reader.read()) != -1) {
            System.out.print((char) b);
        }


    }
}
